const beforeEach = (router: any) => {
  router.beforeEach((to, from, next) => {
    // console.log(to);

    // 在这里进行权限验证、登录判断等操作
    let token: any = useStorage("accessToken");
    // console.log('accessToken', token.value,to)
    // 判断有没有登录
    if (token.value) {
      next();
    } else {
      if (to.path == "/login") {
        next();
      } else {
        router.push("/login");
      }
    }
    // /disk/mian
  });

  router.afterEach((to, from) => {
    // 跳转后的操作
    // console.log("afterEach", to);
  });

  router.beforeResolve((to, from, next) => {
    // 在导航被确认之前的操作
    next();
  });
};
export { beforeEach };
